﻿Public Class AssetWrapper
#Region "Properties"

    Public _assetID As Integer
    Public Property AssetID As Integer
        Get
            Return _assetID
        End Get
        Set(ByVal value As Integer)
            _assetID = value
        End Set
    End Property

    Public _assetName As String
    Public Property AssetName As String
        Get
            Return _assetName
        End Get
        Set(ByVal value As String)
            _assetName = value
        End Set
    End Property

    Public _assetType As String
    Public Property AssetType As String
        Get
            Return _assetType
        End Get
        Set(ByVal value As String)
            _assetType = value
        End Set
    End Property

    Public _assetBarcodeID As String
    Public Property AssetBarcodeID As String
        Get
            Return _assetBarcodeID
        End Get
        Set(ByVal value As String)
            _assetBarcodeID = value
        End Set
    End Property

    Public _modelNo As String
    Public Property ModelNo As String
        Get
            Return _modelNo
        End Get
        Set(ByVal value As String)
            _modelNo = value
        End Set
    End Property

    Public _serialNo As String
    Public Property SerialNo As String
        Get
            Return _serialNo
        End Get
        Set(ByVal value As String)
            _serialNo = value
        End Set
    End Property

    Public _department As String
    Public Property Department As String
        Get
            Return _department
        End Get
        Set(ByVal value As String)
            _department = value
        End Set
    End Property

    Public _predefinedFields As String
    Public Property PredefinedFields As String
        Get
            Return _predefinedFields
        End Get
        Set(ByVal value As String)
            _predefinedFields = value
        End Set
    End Property

    Public _status As String
    Public Property Status As String
        Get
            Return _status
        End Get
        Set(ByVal value As String)
            _status = value
        End Set
    End Property

#End Region

    Public Shared Function ConvertToWrapperList(ByVal userSource As IEnumerable(Of Equipment.DataAccess.Asset)) As List(Of AssetWrapper)
        Dim wrapperList As New List(Of AssetWrapper)

        For Each a In userSource
            Dim w As New AssetWrapper

            w.AssetID = a.AssetID
            w.Status = a.AssetStatus.Description
            w.Department = a.SiteDepartment.Description
            w.AssetBarcodeID = a.BarcodeID
            w.AssetName = a.AssetName
            w.AssetType = a.AssetType.Description
            w.ModelNo = a.ModelNo
            w.SerialNo = a.SerialNo
            w.PredefinedFields = String.Join(vbCrLf, a.AssetFields.Select(Function(f) f.FieldName & " = " & f.FieldValue))

            wrapperList.Add(w)
        Next

        Return wrapperList
    End Function
End Class
